package com.ilop.sthome.utils;

import android.content.Context;

import com.siterwell.familywellplus.R;

import java.util.Locale;

/**
 * @author skygge
 * @Date on 2020-02-25.
 * GitHub：javofxu@github.com
 * email：skygge@yeah.net
 * description：配置布局集合
 */

public class ConfigureUtil {

    /**
     * 默认房间名称
     * @param roomId 房间ID
     * @return 默认名称
     */
    public static String roomName(Context context, String roomId){
        switch (roomId){
            case "00":
                return context.getString(R.string.default_room);
            case "01":
                return context.getString(R.string.living_room);
            case "02":
                return context.getString(R.string.master_bedroom);
            case "03":
                return context.getString(R.string.supine_bedroom);
            case "04":
                return context.getString(R.string.study);
            case "05":
                return context.getString(R.string.kitchen);
            case "06":
                return context.getString(R.string.toilet);
            default:
                return "";
        }
    }

    /**
     * 电量
     * @param q
     * @return
     */
    public static int choseQPic(int q){
        int qResource;
        if(q == 0){
            qResource = imageQ[0];
        }else if(q <= 20){
            qResource = imageQ[1];
        }else if(q <= 40){
            qResource = imageQ[2];
        }else if(q <= 60){
            qResource = imageQ[3];
        }else if(q <= 80){
            qResource = imageQ[4];
        }else{
            qResource = imageQ[5];
        }
        return qResource;
    }

    /**
     * 信号
     * @param s
     * @return
     */
    public static int choseSPic(String s){
        int mResource;
        if("00".equals(s)){
            mResource = imageS[0];
        }else if("01".equals(s)){
            mResource = imageS[1];
        }else if("02".equals(s)){
            mResource = imageS[2];
        }else if("03".equals(s)){
            mResource = imageS[3];
        }else if("04".equals(s)){
            mResource = imageS[4];
        }else {
            mResource = imageS[0];
        }
        return mResource;
    }

    private static int[] imageQ = new int[]{
            R.mipmap.battery0,
            R.mipmap.battery1,
            R.mipmap.battery2,
            R.mipmap.battery3,
            R.mipmap.battery4,
            R.mipmap.battery5
    };

    private static int[] imageS = new int[]{
            R.mipmap.signal0,
            R.mipmap.signal1,
            R.mipmap.signal2,
            R.mipmap.signal3,
            R.mipmap.signal4
    };

    public static int[] sceneColor = new int[]{
            R.color.gateway_color_0,
            R.color.gateway_color_1,
            R.color.gateway_color_2,
            R.color.gateway_color_3,
            R.color.gateway_color_4,
            R.color.gateway_color_5,
            R.color.gateway_color_6,
            R.color.gateway_color_7,
            R.color.gateway_color_8
    };

    /**
     * 状态颜色
     * @param state
     * @return
     */
    public static int choseDeviceStateColor(int state){
        switch (state){
            case 0:
                return R.drawable.device_status_super_alarm;
            case 1:
                return R.drawable.device_status_alarm;
            case 2:
                return R.drawable.device_status_warn;
            case 3:
                return R.drawable.device_status_off_line;
            default:
                return R.drawable.device_status_normal;
        }
    }

    public static String choseLNum(int n){
        String num;
        if(n>100){
            num = "100%";
        }else{
            num = n +"%";
        }
        return num;
    }

    public static int getCommonName(String recommendId){
        switch (recommendId){
            case "01":
                return R.string.home_security;
            case "02":
                return R.string.someone_at_home;
            case "03":
                return R.string.nobody_at_home;
            case "04":
                return R.string.sos_for_help;
            case "05":
                return R.string.push_alarm;
            case "06":
                return R.string.fault_information_push;
            case "08":
                return R.string.door_guard;
            case "09":
                return R.string.open_door;
            case "0A":
                return R.string.close_door;
            case "0B":
                return R.string.sos_for_help;
            case "0C":
                return R.string.custom;
            case "0D":
                return R.string.temperature_alarm;
            case "0E":
                return R.string.humidity_alarm;
            case "0F":
                return R.string.socket_switching;
            case "1A":
                return R.string.timer_on_off;
            case "1B":
                return R.string.linkage_on_off;
            case "1D":
                return R.string.fault_information_push;
            case "1E":
                return R.string.fault_information_push;
            case "1F":
                return R.string.fault_information_push;
            case "10":
                return R.string.doorbell_function;
            case "11":
                return R.string.unlocking_push;
            case "12":
                return R.string.switch_to_at_home;
            case "13":
                return R.string.push_alarm;
            case "14":
                return R.string.push_alarm;
            case "15":
                return R.string.push_alarm;
            case "16":
                return R.string.push_alarm;
            case "17":
                return R.string.push_alarm;
            case "18":
                return R.string.timer_on_off;
            case "19":
                return R.string.linkage_on_off;
            case "20":
                return R.string.fault_information_push;
            case "21":
                return R.string.fault_information_push;
            case "22":
                return R.string.push_alarm;
            case "23":
                return R.string.fault_information_push;
            case "24":
                return R.string.co_alarm_push;
            case "25":
                return R.string.gas_alarm_push;
            case "26":
                return R.string.fault_information_push;
            case "27":
                return R.string.sos_for_help;
            case "28":
                return R.string.linkage_alarm;
            case "29":
                return R.string.timer_on_off;
            case "2A":
                return R.string.linkage_on_off;
            case "2B":
                return R.string.timer_on_off;
            case "2C":
                return R.string.linkage_on_off;
            default:
                return -1;
        }
    }

    public static int getCommonImage(String recommendId){
        switch (recommendId){
            case "01":
                return R.mipmap.device_prevent;
            case "02":
                return R.mipmap.device_turn_on;
            case "03":
                return R.mipmap.device_turn_off;
            case "04":
                return R.mipmap.device_sos;
            case "05":
                return R.mipmap.device_warning;
            case "06":
                return R.mipmap.device_fault;
            case "08":
                return R.mipmap.device_prevent;
            case "09":
                return R.mipmap.device_turn_on;
            case "0A":
                return R.mipmap.device_turn_off;
            case "0B":
                return R.mipmap.device_sos;
            case "0C":
                return R.mipmap.device_auto;
            case "0D":
                return R.mipmap.device_temperature;
            case "0E":
                return R.mipmap.device_humidity;
            case "0F":
                return R.mipmap.device_socket_change;
            case "1A":
                return R.mipmap.device_timing;
            case "1B":
                return R.mipmap.device_linkage;
            case "1D":
                return R.mipmap.device_fault;
            case "1E":
                return R.mipmap.device_fault;
            case "1F":
                return R.mipmap.device_fault;
            case "10":
                return R.mipmap.device_bell;
            case "11":
                return R.mipmap.device_push;
            case "12":
                return R.mipmap.device_home;
            case "13":
                return R.mipmap.device_warning;
            case "14":
                return R.mipmap.device_warning;
            case "15":
                return R.mipmap.device_warning;
            case "16":
                return R.mipmap.device_warning;
            case "17":
                return R.mipmap.device_warning;
            case "18":
                return R.mipmap.device_timing;
            case "19":
                return R.mipmap.device_linkage;
            case "20":
                return R.mipmap.device_fault;
            case "21":
                return R.mipmap.device_fault;
            case "22":
                return R.mipmap.device_warning;
            case "23":
                return R.mipmap.device_fault;
            case "24":
                return R.mipmap.device_warning;
            case "25":
                return R.mipmap.device_warning;
            case "26":
                return R.mipmap.device_fault;
            case "27":
                return R.mipmap.device_sos;
            case "28":
                return R.mipmap.device_fault;
            case "29":
                return R.mipmap.device_timing;
            case "2A":
                return R.mipmap.device_linkage;
            case "2B":
                return R.mipmap.device_timing;
            case "2C":
                return R.mipmap.device_linkage;
            default:
                return -1;
        }
    }

    public static int gridLayoutLineNum(int stringLength){
        if (0 < stringLength && stringLength <= 4) {
            return 1;
        } else if (4 < stringLength && stringLength <= 8) {
            return 2;
        } else if (8 < stringLength && stringLength <= 12) {
            return 3;
        } else {
            return 4;
        }
    }

    public static String getOfficialWebsite(Context context){
        Locale locale = context.getResources().getConfiguration().locale;
        String lan = locale.getLanguage();
        if("zh".equals(lan)){
            return "www.china-siter.cn";
        }else if("en".equals(lan)){
            return "www.china-siter.com";
        }else if("fr".equals(lan)){
            return "www.china-siter.com";
        }else if("de".equals(lan)){
            return "www.china-siter.com";
        }else if("es".equals(lan)){
            return "www.china-siter.com";
        }else {
            return "www.china-siter.com";
        }
    }

    public static String getPrivacyAgreement(Context context){
        Locale locale = context.getResources().getConfiguration().locale;
        String lan = locale.getLanguage();
        if("zh".equals(lan)){
            return "file:///android_asset/register/register_zh.html";
        }else if("en".equals(lan)){
            return "file:///android_asset/register/register_en.html";
        }else if("fr".equals(lan)){
            return "file:///android_asset/register/register_fr.html";
        }else if("de".equals(lan)){
            return "file:///android_asset/register/register_de.html";
        }else if("es".equals(lan)){
            return "file:///android_asset/register/register_es.html";
        }else {
            return "file:///android_asset/register/register_en.html";
        }
    }

    public static String getUserProtocol(Context context){
        Locale locale = context.getResources().getConfiguration().locale;
        String lan = locale.getLanguage();
        if("zh".equals(lan)){
            return "file:///android_asset/userProtocol/user_protocol_zh.html";
        }else if("en".equals(lan)){
            return "file:///android_asset/userProtocol/user_protocol_en.html";
        }else if("fr".equals(lan)){
            return "file:///android_asset/userProtocol/user_protocol_fr.html";
        }else if("de".equals(lan)){
            return "file:///android_asset/userProtocol/user_protocol_de.html";
        }else if("es".equals(lan)){
            return "file:///android_asset/userProtocol/user_protocol_es.html";
        }else {
            return "file:///android_asset/userProtocol/user_protocol_en.html";
        }
    }
}
